<?php if(isset($_SESSION['user']['user_id']) && $_SESSION['user']['user_id']!=""){?>
<div class="col-md-8">
<div class="main-content" id="main-content">
		<div class="sub-content">
			<div class="top-header page-header clearfix">
				<h1>Super Admin Profile</h1>
			</div>
			<div class="top-links">
				<ul class="form-progress-bar">
					<? if(isset($_GET['edit']) && $_GET['edit']!=""){?>
						<li class="active-menu step-no"><a href="<? echo $this->Url('users')?>/user-previous?user_id=<? echo $_GET['user_id'];?>&edit=1"><span>1</span></a></li>
						<li class="indicator"><span></span></li>
						<li class="step-no"><span>2</span></li>
						<li class="indicator"><span></span></li>
						<li class="step-no"><span>3</span></li>
					<?}else if(isset($_GET['user_id']) && $_GET['user_id']!=""){?>
						<li class="step-no "><a href="<? echo $this->Url('users')?>/user-previous?user_id=<? echo $_GET['user_id'];?>"><span>1</span></a></li>
						<li class="indicator"><span></span></li>
						<li class="step-no"><span>2</span></li>
						<li class="indicator"><span></span></li>
						<li class="step-no"><span>3</span></li>
						
					<?}else{?>
						<li class="active-menu step-no"><a href="<? echo $this->Url('users')?>/user-previous"><span>1</span></a></li>
						<li class="step-no"><span>2</span></li>
						<li class="step-no"><span>3</span></li>
					<?}?>	
				</ul>
			</div>
			<div style="float:right;"><?if(isset($_SESSION['user']['gotoBack']) && $_SESSION['user']['gotoBack']!=""){?>
									<a href="<? echo $this->Url('users')?>/goto-back" class="rate-icon"><span>Goto Back</span></a>
							<?}?></div>
		<div class="middle-forms user-profile1 col-md-11">
				<form id="signupForm" name="signupForm"  method="post" class="form-horizontal" role="form">
						<div class="form-group">
							<label class="control-label col-sm-3">Company Name</label>
							<div class="col-sm-9">
							<? if(isset($_SESSION['usersinfo']['cname'])){?>
								<input  type="text" id="cname" name="cname" class="form-control"  value="<? echo $_SESSION['usersinfo']['cname'];?>" placeholder="Company Name"> 
							<?}else if(isset($this->user_details->company_name)){?>
							<? if(isset($_SESSION['user']['user_id']) && $_SESSION['user']['user_id']!=$this->user_details->user_id){?>
								<input  type="text" id="cname" name="cname"  class="form-control" value="<? echo $this->user_details->company_name;?>" placeholder="Company Name"> 
							<?}else{?>
								<input  type="text" id="cname" name="cname" class="form-control" readonly="readonly" value="<? echo $this->user_details->company_name;?>" placeholder="Company Name"> 
							<?}}else{?>
							<input  type="text" id="cname" name="cname" class="form-control" value="" placeholder="Company Name"> 
							<?}?></div>
						</div><span style="color:red" id="errorcname"></span>
						<div class="form-group">
							<label class="control-label col-sm-3">Industry</label>
							<div class="col-sm-9">
							<? if(isset($this->user_details->industry) && $this->user_details->industry){?>
							<? if(isset($_SESSION['user']['user_id']) && $_SESSION['user']['user_id']!=$this->user_details->user_id){?>
							<div class="select_6">
								<select id="industry" name="industry" class="form-control">
									<option value="">-Select a industry</option>	
									<?php if(isset($this->getallindustries) && count($this->getallindustries)>0){foreach($this->getallindustries as $industries){										
									if($_SESSION['usersinfo']['industry']==$industries->industry_id){?>
									     <option value="<? echo $industries->industry_id.'/'.$industries->industryname;?>" selected="selected"><? echo $industries->industryname;?></option>
									<?}else if($this->user_details->industry==$industries->industry_id){?>
										<option value="<? echo $industries->industry_id.'/'.$industries->industryname;?>" selected="selected"><? echo $industries->industryname;?></option> 
									<?}else{?>
										<option value="<? echo $industries->industry_id.'/'.$industries->industryname;?>"><? echo $industries->industryname;?></option> 
									<?}}}?>	
								</select>
							</div>
							<?}else{?>	
							    <input type="text" readonly="readonly" class="form-control" id="industry" name="industry" value="<? echo $this->user_details->industryname;?>">
								<input type="hidden" value="<? echo $this->user_details->industry;?>">
							<?}}else{?>
							<div class="select_6">
								<select id="industry" name="industry"  readonly="readonly" class="form-control">
									<option value="">-Select a industry</option>	
									<?php if(isset($this->getallindustries) && count($this->getallindustries)>0){foreach($this->getallindustries as $industries){										
									if(isset($_SESSION['usersinfo']['industry']) && $_SESSION['usersinfo']['industry']==$industries->industry_id){?>
										<option value="<? echo $industries->industry_id.'/'.$industries->industryname;?>" selected="selected"><? echo $industries->industryname;?></option> 
									<?}else{?>
										<option value="<? echo $industries->industry_id.'/'.$industries->industryname;?>"><? echo $industries->industryname;?></option> 
									<?}}}?>	
								</select>
							</div>
							<?}?></div>
						</div><span style="color:red" id="errorindustry"></span>
						<div class="form-group">
							<label class="control-label col-sm-3">Address 1</label>
							<div class="col-sm-9">
							<? if(isset($_SESSION['usersinfo']['address1'])){?>
								<textarea  class="profile_add form-control" id="address1" name="address1" ><? echo $_SESSION['usersinfo']['address1'];?></textarea>
							<? } else if(isset($this->user_details->address1)){
								if(isset($_SESSION['user']['user_id']) && $_SESSION['user']['user_id']!=$this->user_details->user_id){?>
									<textarea  class="profile_add form-control" id="address1"  name="address1" ><? echo $this->user_details->address1;?></textarea>
								<?}else{?>	
									<textarea  class="profile_add form-control" id="address1" readonly="readonly" name="address1" ><? echo $this->user_details->address1;?></textarea>
							<?}}else{?>
								<textarea  class="profile_add form-control" id="address1" name="address1" ></textarea>
							<?}?></div>
						</div><span style="color:red" id="erroraddress1"></span>
						<div class="form-group">
							<label class="control-label col-sm-3">Address 2</label>							
							<div class="col-sm-9">
							<? if(isset($_SESSION['usersinfo']['address2'])){?>
								<textarea  class="profile_add form-control" id="address2" name="address2" ><? echo $_SESSION['usersinfo']['address2'];?></textarea>
							<?}else if(isset($this->user_details->address2)){?>
								<? if(isset($_SESSION['user']['user_id']) && $_SESSION['user']['user_id']!=$this->user_details->user_id){?>
									<textarea class="profile_add form-control" id="address2" name="address2" ><? echo $this->user_details->address2;?></textarea>
								<?}else{?>
									<textarea class="profile_add form-control" id="address2" name="address2"   readonly="readonly" ><? echo $this->user_details->address2;?></textarea>
							<?}}else{?>
									<textarea  class="profile_add form-control" id="address2" name="address2" ></textarea>
							<?}?></div>
						</div><span style="color:red" id="erroraddress2"></span>
						<div class="form-group ">
							<label class="control-label col-sm-3">Address 3</label>
							<div class="col-sm-9">
							<? if(isset($_SESSION['usersinfo']['address3'])){?>
								<textarea  class="profile_add form-control" id="address3" name="address3"   ><? echo $_SESSION['usersinfo']['address3'];?></textarea>
							<?}else if(isset($this->user_details->address3)){?>
								<? if(isset($_SESSION['user']['user_id']) && $_SESSION['user']['user_id']!=$this->user_details->user_id){?>
									<textarea  class="profile_add form-control" id="address3" name="address3" ><? echo $this->user_details->address3;?></textarea>
								<?}else{?>
									<textarea  class="profile_add form-control" id="address3" name="address3"  readonly="readonly" ><? echo $this->user_details->address3;?></textarea>
								<?}}else{?>
								<textarea  class="profile_add form-control" id="address3" name="address3" ></textarea>
							<?}?></div>
						</div><span style="color:red" id="erroraddress3"></span>
						<div class="form-group">
							<label class="control-label col-sm-3">Landmark Near By</label>
							<div class="col-sm-9">
							<? if(isset($_SESSION['usersinfo']['lmnear'])){?>
									<input  type="text" id="lmnear" name="lmnear"  class="form-control"  value="<? echo $_SESSION['usersinfo']['lmnear'];?>" placeholder="Landmark Near By" />
							<?} else if(isset($this->user_details->landmarknearby)){?>
								<? if(isset($_SESSION['user']['user_id']) && $_SESSION['user']['user_id']!=$this->user_details->user_id){?>
									<input  type="text" id="lmnear" name="lmnear" class="form-control" value="<? echo $this->user_details->landmarknearby;?>" placeholder="Landmark Near By" />
								<?}else{?>
									<input type="text" id="lmnear" name="lmnear"  class="form-control" readonly="readonly"  value="<? echo $this->user_details->landmarknearby;?>" placeholder="Landmark Near By" />
							<?}}else{?>
								<input  type="text" id="lmnear" name="lmnear" class="form-control"  value="" placeholder="Landmark Near By" />
							<?}?></div>
						</div><span style="color:red" id="errorlmnear"></span>
						<div class="form-group">
							<label class="control-label col-sm-3">City</label>							
							<div class="col-sm-9">
							<? if(isset($_SESSION['usersinfo']['city'])){?>
								<input  type="text" id="city"  value="<? echo $_SESSION['usersinfo']['city'];?>" name="city" placeholder="Please enter city"/>
							<?}else if(isset($this->user_details->city)){?>
								<? if(isset($_SESSION['user']['user_id']) && $_SESSION['user']['user_id']!=$this->user_details->user_id){?>
									<input  type="text" id="city" class="form-control" value="<? echo $this->user_details->city;?>" name="city" placeholder="Please enter city"/>
								<?}else{?>
									<input  type="text" id="city" class="form-control" readonly="readonly" value="<? echo $this->user_details->city;?>" name="city" placeholder="Please enter city"/>
							<?}}else{?>
									<input  type="text" id="city" value="" class="form-control" name="city" placeholder="Please enter city"/>
							<?}?></div>
						</div><span style="color:red" id="errorcity"></span>
						<div class="form-group">
							<label class="control-label col-sm-3">Country</label>
							
							<? if(isset($this->user_details->country) && $this->user_details->country!=""){?>
							<? if(isset($_SESSION['user']['user_id']) && $_SESSION['user']['user_id']!=$this->user_details->user_id){?>
								<div class="select_6 col-sm-9">
									<select id="country" name="country" class="form-control" >
									    <option value="">-Select a country</option>	
										<?php if(isset($this->countries) && count($this->countries)>0){foreach($this->countries as $countries){										
										if($_SESSION['usersinfo']['country']==$countries->country_id){?>
										  <option value="<? echo $countries->country_id.'-'.$countries->nicename;?>" selected="selected"><? echo $countries->nicename;?></option>
										<?}else if($this->user_details->country==$countries->country_id){?>
											<option value="<? echo $countries->country_id.'-'.$countries->nicename;?>" selected="selected"><? echo $countries->nicename;?></option> 
										<?}else{?>
											<option value="<? echo $countries->country_id.'-'.$countries->nicename;?>"><? echo $countries->nicename;?></option> 
										<?}}}?>	
									</select>
								</div>
							<?}else{?><div class="col-sm-9">
							    <input type="text" readonly="readonly" class="form-control" value="<? echo $this->user_details->usercountry;?>">
								<input type="hidden" id="country" name="country"  value="<? echo $this->user_details->country;?>"></div>
							<?}}else{?>
								<div class="select_6 col-sm-9">
									<select id="country" name="country"  readonly="readonly" class="form-control">
										<option value="">-Select a country</option>	
										<?php if(isset($this->countries) && count($this->countries)>0){foreach($this->countries as $countries){										
										if(isset($_SESSION['usersinfo']['country']) && $_SESSION['usersinfo']['country']==$countries->country_id){?>
											<option value="<? echo $countries->country_id.'-'.$countries->nicename;?>" selected="selected"><? echo $countries->nicename;?></option> 
										<?}else{?>
											<option value="<? echo $countries->country_id.'-'.$countries->nicename;?>"><? echo $countries->nicename;?></option> 
										<?}}}?>	
									</select>
								</div>
							<?}?>
							<div style="clear:both"></div>
						</div><span id="errorcountry" style='color:red';></span>
						
						<div class="form-group">
							<label class="control-label col-sm-3">Email</label>
							<div class="col-sm-9">
							<? if(isset($_SESSION['usersinfo']['email'])){?>
								<input  type="text" id="email" name="email"  class="form-control" value="<? echo $_SESSION['usersinfo']['email'];?>" placeholder="Email" />
							<?}else if(isset($this->user_details->email)){?>
								<? if(isset($_SESSION['user']['user_id']) && $_SESSION['user']['user_id']!=$this->user_details->user_id){?>
									<input  type="text" id="email" name="email" class="form-control" value="<? echo $this->user_details->email;?>" placeholder="Email" />
								<?}else{?>
									<input  type="text" id="email" name="email" class="form-control" readonly="readonly" value="<? echo $this->user_details->email;?>" placeholder="Email" />
							<?}}else{?>
								<input  type="text" id="email" name="email" class="form-control" onblur="emailSucc()" value="" placeholder="Email" />
							<?}?></div>
						</div><span id="error" style="color:red"></span> 
						      <span id="emptyemail" style="color:red"></span> 
						     <span style="color:red" id="erroremail"></span>
						<div class="form-group">
							<label class="control-label col-sm-3">Phone </label>
							<div class="col-sm-9">
							<?  if(isset($_SESSION['usersinfo']['phone'])){?>
								<input  type="text" id="phone" name="phone" class="form-control" value="<? echo $_SESSION['usersinfo']['phone'];?>" placeholder="Phone" />
							<?}else if(isset($this->user_details->phone)){?>
							<? if(isset($_SESSION['user']['user_id']) && $_SESSION['user']['user_id']!=$this->user_details->user_id){?>
								<input  type="text" id="phone" name="phone" class="form-control"  value="<? echo $this->user_details->phone;?>" placeholder="Phone" />
							<?}else{?>
								<input  type="text" id="phone" name="phone" class="form-control" readonly="readonly" value="<? echo $this->user_details->phone;?>" placeholder="Phone" />
							<?}}else{?>
								<input  type="text" id="phone" name="phone" class="form-control" value="" placeholder="Phone" />
							<?}?></div>						
						</div><span style="color:red" id="errorphone"></span>
						<div class="form-group">
							<label class="control-label col-sm-3">Fax </label>
							<div class="col-sm-9">
							<? if(isset($_SESSION['usersinfo']['fax'])){?>
								<input  type="text" id="fax" name="fax"  class="form-control" placeholder="Fax" value="<? echo $_SESSION['usersinfo']['fax'];?>" />
							<?}else if(isset($this->user_details->fax)){?>
								<? if(isset($_SESSION['user']['user_id']) && $_SESSION['user']['user_id']!=$this->user_details->user_id){?>
									<input  type="text" id="fax" name="fax" class="form-control"  placeholder="Fax" value="<? echo $this->user_details->fax;?>" />
								<?}else{?>
								<input  type="text" id="fax" name="fax" class="form-control"  readonly="readonly" placeholder="Fax" value="<? echo $this->user_details->fax;?>" />
	                        <?}}else{?>
								<input  type="text" id="fax" name="fax" class="form-control" placeholder="Fax" value="" />
							<?}?></div>
						</div><span style="color:red" id="errorfax"></span>
						<input type="hidden" id="hid_user_id" name="hid_user_id" value="<? if(isset($this->user_details->user_id)){echo $this->user_details->user_id;}?>">
						<input type="hidden" id="exit_email" name="exit_email" value="0">
						<input type="hidden" id="edit_status" name="edit_status" value="<? if(isset($_GET['edit'])){echo $_GET['edit'];}?>">				<div class="form-group">
						<label class="col-sm-3">&nbsp;</label>
							<a href="javascript:void(0)"  id="continue" onclick="validate();" class="btn btn-danger" role="button">Continue</a>
							
						</div>
					
				</form>
		</div>
	</div>
</div></div>
<script type="text/javascript">
	function validate(){
	    var flag=true;	
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		var letters = /^[a-zA-Z ]*$/;
       //var valid1 = /^[0-9]+$/;        
		var validpattern = /^[+-]?\d+$/;
		//var valid3=/^[\d\s() -]+$/;
		var companyname=$('#cname').val();
		var industry=$('#industry').val();
		var address1=$('#address1').val();
		var address2=$('#address2').val();
		var address3=$('#address3').val();
		var landmarknearby=$('#lmnear').val();
		var city=$('#city').val();
		var country=$('#country').val();
		var emailcheck=$('#email').val();
		var pnumber=$('#phone').val();
		var fax=$('#fax').val();
		var exit_email=$("#exit_email").val();
		if(companyname==""){
			$('#errorcname').html('*Company name is required');	
			flag=false;
		}else{
			$('#errorcname').html('');
		}
		
		if(industry==""){
			$('#errorindustry').html('*Industry is required');	
			flag=false;
		}else{
			$('#errorindustry').html('');
		}
		if(address1==""){
			$('#erroraddress1').html('*Address filed is required');
			flag=false;
		}else{
			 $('#erroraddress1').html('');
		}
		if(address2==""){
			$('#erroraddress2').html('*Address filed is required');
			flag=false;
		}else{
			 $('#erroraddress2').html('');
		}
        if(address3==""){
			$('#erroraddress3').html('*Address filed is required');
			flag=false;
		}else{
			 $('#erroraddress3').html('');
		}
		if(landmarknearby==""){
			$('#errorlmnear').html('*Land mark near by is required');	
			flag=false;
		}else{
			$('#errorlmnear').html('');
		}
		if(city==""){
			$('#errorcity').html('*City is required');
			flag=false;
		}else{
			$('#errorcity').html('');
		}
		if(country==""){
			$('#errorcountry').html('*Country required');
			flag=false;
		}else{
			$('#errorcountry').html('');
		}
		if(emailcheck==""){
		  $('#erroremail').html('*User email is required');
		  flag=false;
		}else if(!filter.test(emailcheck)){
		  $('#erroremail').html('Email format is not correct');
		  $("#error").html("");
		  flag=false;
		}else if(exit_email=='1'){
			$('#erroremail').html('');
			 $("#error").html("User is already exits");
			flag=false;
		}else{
		   $('#erroremail').html('');
		}
		if(pnumber==""){
		  $('#errorphone').html('*Phone number is required');
		  flag=false;
		}else if(!pnumber.match(validpattern)){
		     $('#errorphone').html('*Invalid phone number');
			   flag=false;
		}else{
		 $('#errorphone').html('');
		}
		if(fax==""){
			$('#errorfax').html('*Fax is required');	
			flag=false;
		}else if(isNaN(fax)){
		    $('#errorfax').html('Numbers only');
			flag=false;
		}else{
			$('#errorfax').html('');
		}
		if(flag==false){ 
			return false;
		}else{		
			$("#signupForm").submit();
		}
	}
	function emailSucc(){
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		flag=true;
		  var emailcheck=$('#email').val();
		   if(emailcheck==""){
		     $('#erroremail').html('*User email is required');
			 flag=false;
		   }else if(!filter.test(emailcheck)){
			$('#erroremail').html('Email format is not correct');
			$("#error").html("");
			flag=false;
			}
			if(flag==false){ 
				return false;
			}else{
				   $.ajax({
					url:BASE_PATH+"/users/checkregemail",
					type:"POST",
					data:{email:emailcheck},
					success: function(data){
					 if(data.output=='success'){
						$("#exit_email").val('1');
						$('#erroremail').html('');
						$("#error").html("User is already exits");			 
						}else{
							$("#exit_email").val('0');
							$("#error").html("");
							$('#erroremail').html('');
						}
					},
				});
			}
   }
</script>
<?php }else{?>
<script>
	window.location='<? echo $this->Url('home')?>';
</script>
<?php }?>
	

        